<include file="Index/nav"/>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12 col-md-12">
            <form id='msgform' action='<{:U("Index/postMsg")}>' method="post" style="display: none"></form>
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    
                </div>
                <div class="panel-body">
                    <h4 class="text-muted">请输入短信内容　<small>(已输入 <kbd id='hip'>0</kbd> 字，还可输入 <kbd id='words'>500</kbd> 字，最多500字，统计 <kbd id='ts'>0</kbd> 条)</small></h4>
                    <p style="margin-bottom: 20px;"><textarea name='msgcontent' form='msgform' class='form-control msgcontent' rows='5' placeholder="短信内容（最多500字）" autofocus required style="resize: none;"></textarea></p>
                    <h4 class="text-muted">请选择签名</h4>
                    <p style="margin-bottom: 20px;">
                        <select class="input-sm" name="sign" form="msgform">
                            <option value="<{:C('DEFAULT_SIGNATURE')}>"><{$Think.config.DEFAULT_SIGNATURE}></option>
                            <foreach name="signat" item="vo">
                                <option value="<{$vo.signature}>"><{$vo.signature}></option>
                            </foreach>
                        </select>
                    </p>
                    <h5>这里显示的用户是从今天起30天内将要到期的用户</h5>
                </div>
                <!-- Table -->
                <table class="table table-hover table-bordered text-center">
                    <thead>
                        <tr>
                            <th class="text-center"><input type='checkbox' class='checkall'></th>
                            <th class="text-center">用户状态</th>
                            <th class="text-center">联系电话</th>
                            <th class="text-center">帐号</th>
                            <th class="text-center">用户姓名</th>
                            <th class="text-center">所属小区</th>
                            <th class="text-center">所属营业厅</th>
                            <th class="text-center">到期时间</th>
                        </tr>
                    </thead>
                    <tbody>
                    <foreach name="users" item="user">
                        <tr>
                            <td><input form='msgform' type="checkbox" class="userPhone" name='phones[]' value="<notempty name='user.PHONE'><{$user.PHONE}></notempty>"></td>
                            <td>
                                <switch name="user.STATUS">
                                    <case value="1"><span class='btn btn-xs btn-success'>激活</span></case>
                                    <case value="2"><span class='btn btn-xs btn-danger'>停机</span></case>
                                    <case value="3"><span class='btn btn-xs btn-danger'>销户</span></case>
                                    <case value="4"><span class='btn btn-xs btn-danger'>欠停</span></case>
                                </switch>
                            </td>
                            <td><notempty name="user.PHONE"><{$user.PHONE}></notempty></td>
                            <td><{$user.CUSTCODE}></td>
                            <td><{$user.CUSTNAME}></td>
                            <td><{$user.UNITYNAME}></td>
                            <td><{$user.YYTMC}></td>
                            <td><{$user.ENDDATE|substr=0,4}>-<{$user.ENDDATE|substr=4,2}>-<{$user.ENDDATE|substr=6,2}> <{$user.ENDDATE|substr=8,2}>:<{$user.ENDDATE|substr=10,2}>:<{$user.ENDDATE|substr=12,2}></td>
                        </tr>
                    </foreach>
                        <tr>
                            <td colspan="8"><button form='msgform' class='btn btn-primary sendmsg form-control'>发送短信</button></td>
                        </tr>
                    </tbody>
                </table>
                <div class='panel-footer'>
                    <{$page}>
                </div>
            </div>
        </div>
    </div>
</div>
<!--<script type="text/javascript" src="__PUBLIC__/laydate/laydate.js"></script>-->
<script>
   $('.checkall').click(function(){
      $('.userPhone').each(function(){
         $(this).prop('checked', !!$('.checkall').prop('checked'));
      }); 
   });
   $('.msgcontent').keyup(function(){
       if($(this).val().length > 500) {
           $(this).val($(this).val().substring(0, 500));
       }
       $('#hip').text($(this).val().length);
       $('#words').text(500 - $(this).val().length);
       $('#ts').text(Math.ceil($(this).val().length / 70));
   });
   $('.sendmsg').click(function() {
       if ($('.userPhone:checked').length == 0) {
           alert('请选择接收短信的用户');
           return false;
       }
       return true;
   });
//   laydate({
//        elem: '#sendtime', 
//        event: 'focus',
//        format: 'YYYY/MM/DD hh:mm:ss',
//        min: laydate.now(),
//        istime: true
//    });
</script>